#!/usr/bin/perl

use strict;

print "[master-pipeline] master_pipeline.pl\n\n";

# first step
# update the available RPFITS files
my $command="/data/MENTOK_2/ste616/flux_monitoring/scripts/add_new_rpfits.pl";
&execute_command($command);

# second step
# make some summary plots
$command="/data/MENTOK_2/ste616/flux_monitoring/scripts/db_observation_summary_plot.pl";
&execute_command($command);

# third step
# extract source files from RPFITS
$command="/data/MENTOK_2/ste616/flux_monitoring/scripts/process_files.pl";
&execute_command($command);

# fourth step
# update the calibration table
$command="/data/MENTOK_2/ste616/flux_monitoring/scripts/update_calibrate_table.pl";
&execute_command($command);

# fifth step
# execute the reduction pipeline
$command="/data/MENTOK_2/ste616/flux_monitoring/scripts/new_calibration_pipeline_reduction.pl";
&execute_command($command);

# sixth step
# remove any unneeded files
$command="/data/MENTOK_2/ste616/flux_monitoring/scripts/remove_processed_files.pl";
&execute_command($command);

sub execute_command {
    my $command=$_[0];
    print "[execute_command] running ".$command."\n";

    system $command;
}
